<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
	$member=pdo_get('jy_mapfuwu_worker',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$info=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	if(!$member){
		exi('','error','/zmcz/');
	}else{
		$member['user']='worker';
		$this->model('worker')->check_busy($member['id']);
	}
	$member['nickname']=$info['nickname'];
	$member['avatar']=$info['avatar'];
	$member['credit2']=$info['credit2'];
if($_RQ['op']=='main'){
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$return['daystatus5']=pdo_count('jy_mapfuwu_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id'],'onend_time >'=>$daytime),'id');
	$return['allstatus5']=pdo_count('jy_mapfuwu_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id']),'id');
	$dayfee=pdo_getsum('jy_mapfuwu_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id'],'onend_time >'=>$daytime),'price');
	if($return['pluginset']['fee_price']){
			$daymyfee=$return['pluginset']['fee_price']*$return['daystatus5'];
	}elseif($return['pluginset']['fee_rate']){
			$daymyfee=(100-$return['pluginset']['fee_rate'])*$dayfee/100;
	}
	$return['daymyfee']=$daymyfee;
	$return['dayfee']=$dayfee;
	$return['member']=$member;
	$return['role']=$_SESSION['role'];
	if($return['pluginset']['shenhe_members']){
		foreach($return['pluginset']['shenhe_members'] as $sv){
			if($sv['mid']==$_SESSION['uid']){
				$return['isshenhe_member']=1;
				break;
			}
		}
	}
	$return['store']=pdo_get('jy_mapfuwu_store',array('id'=>$member['store_id']),array('id','title','name','mobile','image','mid','address','pcd'));
	$return['store']['image']=tomedia($return['store']['image']);
	$return['store']['pcd']=json_decode($return['store']['pcd'],true);
	exi($return);
}
if($_RQ['op']=='set'){
	$member1=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	$info = pdo_get('jy_mapfuwu_worker',array('mid'=>$_SESSION['uid']));
	$info['user']='worker';
	$member=array_merge($member1,$info);
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(strlen($postdata['mobile'])!=11){
			exi('手机号输入有误','error');
		}
		$data=array(
				'name'=>$postdata['name'],
				'mobile'=>$postdata['mobile'],
				'avatar'=>$postdata['avatar'],
		);
		pdo_update('jy_mapfuwu_worker',$data,array('mid'=>$_SESSION['uid']));
		exi('修改成功','','jy_mapfuwu/home/');	
	}
	$member['mobile']=$member['mobile']?intval($member['mobile']):'';
	$member['nickname']=$member1['nickname'];
	$member['avatar']=$member1['avatar'];
	$member['name']=$member1['nickname'];
	$return['member']=$member;
	exi($return);
}